#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/wait.h>
#include <stdlib.h>

int main()
{
    pid_t id = fork();
    if(0 == id)
    {
        //child
        char* const argv[] = {
            "ls", 
            "-a", 
            "-l", 
            NULL
        };
        printf("pid: %d, execl command begin\n", getpid());
        execv("/usr/bin/ls", argv);  
        printf("pid: %d, execl command end\n", getpid());
        exit(1);
    }
    else
    {
        pid_t rid = waitpid(-1, NULL, 0);
        if(rid > 0)
        {
            printf("wait success, rid: %d!\n", rid);
        }
    }
    return 0;
}
